home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
emerald
/
emrldsys.lha
/
Language
/
Compiler
/
genjump.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-16
|
3KB
|
98 lines
#include "datadesc.h"
#include "genutils.h"
#include "allocate.h"
#include "emit.h"
#include "option.h"
static DD jumpDebugArea;
static DD scratch;
#define FIRSTTODEBUG MINALLOCATABLE
#define LASTTODEBUG MAXALLOCATABLE
#define NUMTODEBUG (LASTTODEBUG - FIRSTTODEBUG + 1)
static DD jumpDebugAll[NUMTODEBUG];
#define min(A, B) ((A) < (B) ? (A) : (B))
void jumpDebug()
{
register int i;
DD reg, scratch_plus;
IFOPTION(debugstack, 1) {
assert (jumpDebugArea.value.address.base == regs_l);
reg = buildRegisterDDNC(regs_scratch);
scratch_plus = buildAddressDD(regs_scratch, 0);
scratch_plus.value.address.autoIncrement = TRUE;
emitMove(scratch, pusher, 'l');
emitMoveAddress(jumpDebugArea, scratch);
for (i = FIRSTTODEBUG; i <= LASTTODEBUG; i++) {
reg.value.address.offset = i;
emitMove(reg, scratch_plus, 'l');
}
emitMove(popper, scratch, 'l');
}
emit(SETLASTJUMPFROM);
}
void jumpCheck()
{
register int i;
DD reg, scratch_plus;
IFOPTION(debugstack, 1) {
reg = buildRegisterDDNC(regs_scratch);
scratch_plus = buildAddressDD(regs_scratch, 0);
scratch_plus.value.address.autoIncrement = TRUE;
emitMove(scratch, pusher, 'l');
emitMoveAddress(jumpDebugArea, scratch);
for (i = FIRSTTODEBUG; i <= LASTTODEBUG; i++) {
reg.value.address.offset = i;
emit("\tcmpl\t");
writeDD(scratch_plus, ',');
writeDD(reg, '\n');
emit("\tj%s\t7f\n", JN(EQL));
#ifdef sun
emit("\tstop\t#0000\n");
#endif
#ifdef vax
emit("\thalt\n");
#endif
emit("7:");
}
emitMove(popper, scratch, 'l');
}
}
void initializeJumpDebug()
{
register int i, diff;
IFOPTION(debugstack, 1) {
scratch = buildRegisterDDNC(regs_scratch);
jumpDebugArea = buildAddressDD(regs_l, 0);
for (i = 0; i < NUMTODEBUG; i++) {
jumpDebugAll[i] = buildAddressDD(regs_l, TS_Allocate(4, DataBrand));
assert(jumpDebugAll[i].value.address.offset < 0);
if (i == 0) {
} else if (i == 1) {
diff = jumpDebugAll[1].value.address.offset - jumpDebugAll[0].value.address.offset;
assert(diff == 4 || diff == -4);
} else {
assert(jumpDebugAll[i].value.address.offset - jumpDebugAll[i-1].value.address.offset == diff);
}
if (jumpDebugAll[i].value.address.offset < jumpDebugArea.value.address.offset) {
jumpDebugArea = jumpDebugAll[i];
}
}
}
}
void finalizeJumpDebug()
{
register int i;
IFOPTION(debugstack, 1) {
for (i = 0; i < NUMTODEBUG; i++) {
TS_Free(jumpDebugAll[i].value.address.offset);
}
jumpDebugArea = nullDD;
}
}